<script type="text/javascript">
function check_edit_cat_form()
{
	display('&nbsp;','alert_cat_id');
	display('&nbsp;','alert_cat_name');
	
	var frm_name=document.getElementById("frm_cat_new");
	var aCheck = new Array(); 
 	
	aCheck.push ( new Array('product_category_name', 1, 200, "{CATEGORY.input_category_name}", false, false,'alert_cat_name') );
	var bRes = validateFields(aCheck);
	if(!bRes)
	{
		return;
	}
	else
	{			
			frm_name.submit();
	}		
	
	
}

function check_exits_id(e)
{

	var unicode=e.charCode? e.charCode : e.keyCode;
		if(unicode==13)
		{
			doCheckExitsId();
		}
		if ((unicode!=8)&&(unicode!=9)&&(unicode!=37)&&(unicode!=38)&&(unicode!=39)&&(unicode!=40)&&(unicode!=46)&&(unicode!=44))
			{
					if (unicode<48||unicode>57) //if not a number
					if(unicode!=32)
					return false; //disable key press
					
			}
}
function doCheckExitsId()
{
		var id=document.getElementById('product_category_yahoo_id').value;
		if(id=='')
			return;
		var old_id=document.getElementById('product_category_yahoo_id_old').value;
		if(id==old_id)
		{
			display("{CATEGORY.not_exits_id}","alert_cat_id");
			return;
		}
		
		display("Loading...","ajax_loading2");
		oXMLHttp = checkXMLHTTP();
		var setRequest = typeof(oXMLHttp.setRequestHeader);
		if ( oXMLHttp && setRequest!="undefined" )
		{
			var myQuery = "&checkid="+id;	
			orderPost( oXMLHttp, "{URL_SITE}admin/?sMod=category_index&sAction=check_exits_id", myQuery, HTTPshowCheckExitsId, true );
		}
}
function HTTPshowCheckExitsId()
{
   if ( typeof(oXMLHttp)==='undefined' )
       return;
    // Return status of XMLHttp object
    if ( oXMLHttp.readyState==4 )
    {
        // if oXMLHttp.status is OK
        if ( oXMLHttp.status==200 )
        {
			sRes = ((oXMLHttp.responseText));
			oJson = sRes.parseJSON(); 			
			 if ( typeof( oJson ) === 'object' )
                {
						var result=oJson['BODY']['RES'];	
						if(result!=false)
						{
							display("{CATEGORY.exits_id}","alert_cat_id")
							document.getElementById('product_category_id').focus();
						}
						else
						{
							display("{CATEGORY.not_exits_id}","alert_cat_id");
						}
						display("&nbsp;","ajax_loading2");
				}	
		}
        if ( oXMLHttp.status==404)
        {
            alert("Page not found");
        }
    }

}
</script>
<div class="top_list_page"></div>
<form name="frmUpdate" id="frm_cat_new" action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="sAction" value="do_edit" /> 
<input type="hidden" name="product_category_id" id="product_category_id" value="{product_category_id}" />
<input type="hidden" name="parent_category_id" value="{parent_category_id}" /> 
<input type="hidden" name="parent_category_name" value="{parent_category_name}" /> 
<input type="hidden" name="current_level" value="{current_level}" /> 
<input type="hidden" name="cate_dir" value="{cate_dir}" /> 
<table class="adminform" >
  <tr>
    <th colspan="2" scope="col">&nbsp;<span class="ajax_loading" id="ajax_loading2">&nbsp;</span></th>
    </tr>
	
  <tr>
    <td width="150">{CATEGORY.categoryid}:</td>
    <td>
		<input type="text" name="product_category_yahoo_id" id="product_category_yahoo_id" class="txtbox" value="{product_category_yahoo_id}" onkeypress="return check_exits_id(event);"  />
		<input type="hidden" name="product_category_yahoo_id_old" id="product_category_yahoo_id_old" class="txtbox" value="{product_category_yahoo_id_old}"  />
		<img src="{URL_TEMPLATE_ADMIN}image/tree_img/question.gif" title="{CATEGORY.check_exits_id}" style="cursor:pointer" onclick="javascript:doCheckExitsId();" />
		<span id="alert_cat_id" class="error">&nbsp;</span>
	</td>
  </tr>
  <tr>
  	 <td >{CATEGORY.parent}:</td>
     <td><input type="text"  class="txtbox" name="product_category_parent_name" id="product_category_parent_name" value="{product_category_parent_name}" readonly="true"/> </td>
  </tr>
  <tr>
    <td>{CATEGORY.categoryname}<span class="require">*</span> :</td>
    <td>
		<input type="text" name="product_category_name" id="product_category_name" class="txtbox" value="{product_category_name}" />
		<span id="alert_cat_name" class="error">&nbsp;</span>
	</td>
  </tr>
  <tr>
    <td>{CATEGORY.category_descrition} : </td>
    <td>
		<textarea name="product_category_description">{product_category_description}</textarea>
	</td>
  </tr>
  <tr>
    <td>{CATEGORY.icon} :</td>
    <td>
		<img src="{product_category_image_old_display}" onerror="this.width=0;this.height=0;" /><br />
   		<input type="file" name="product_category_image" id="product_category_image" value="{product_category_image}" />
   		 <input type="hidden" name="product_category_image_old" id="product_category_image_old" value="{product_category_image_old}">
	</td>
  </tr>
  <tr>
    <td>{CATEGORY.status} :</td>
    <td><input type="checkbox" name="product_category_status" {product_category_status} /> {FORM.active}</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

</form>